package com.cetcs.kmga.dataView.dao;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;

import javax.sql.DataSource;
import java.lang.reflect.Method;

/**
 * Created by Administrator on 2018/1/24 0024.
 */
public class DataSourceAspect implements MethodBeforeAdvice,AfterReturningAdvice {

    @Override
    public void afterReturning(Object returnValue, Method method,
                               Object[] args, Object target) throws Throwable {
        // TODO Auto-generated method stub
        DataSourceContextHolder.clearDataSourceType();
    }

    @Override
    public void before(Method method, Object[] args, Object target)
            throws Throwable {

//        if (method.isAnnotationPresent(DataSource.class))
//        {
//            DataSource datasource = method.getAnnotation(DataSource.class);
//            DataSourceContextHolder.setDataSourceType(datasource.name());
//        }
//        else
//        {
//            DataSourceContextHolder.setDataSourceType(SinoConstant.DataSourceType.unityDataSource.toString());
//        }

    }
}
